<?php 
global $wpdb;

$status = ( $_GET['status']=='' ? 'all' : $_GET['status']);
$results = ( $status=='all' ? $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."properties`") : $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."properties` WHERE status='$status'"));
$count_all =& count($wpdb->get_results("SELECT * FROM `".$wpdb->prefix."properties`"));
$count_available =& count($wpdb->get_results("SELECT * FROM `".$wpdb->prefix."properties` WHERE status = 'available'"));
$count_unavailable =& count($wpdb->get_results("SELECT * FROM `".$wpdb->prefix."properties` WHERE status = 'unavailable'"));
$count_featured =& count($wpdb->get_results("SELECT * FROM `".$wpdb->prefix."properties` WHERE status = 'featured'"));
?>

<ul class="subsubsub">
<li><a href='admin.php?page=propmanager.php' <?php if($status=='all'){echo 'class="current"';} ?>>All <span class="count">(<?php echo $count_all ?>)</span></a> |</li>
<li><a href='admin.php?page=propmanager.php&status=available'  <?php if($status=='available'){echo 'class="current"';} ?>>Available <span class="count">(<?php echo $count_available ?>)</span></a> |</li>
<li><a href='admin.php?page=propmanager.php&status=unavailable'  <?php if($status=='unavailable'){echo 'class="current"';} ?>>Unavailable <span class="count">(<?php echo $count_unavailable ?>)</span></a> |</li>
<li><a href='admin.php?page=propmanager.php&status=featured'  <?php if($status=='featured'){echo 'class="current"';} ?>>Featured <span class="count">(<?php echo $count_featured ?>)</span></a></li></ul>

<div class="tablenav">
<div class="alignleft actions">
	<select name="op">
		<option value="-1" selected="selected">Bulk Actions</option>
		<option value="available">Set Available</option>
		<option value="unavailable">Set Unavailable</option>
		<option value="featured">Set Featured</option>
		<option value="delete">Delete</option>
	</select>
	<input type="submit" value="Apply" name="doaction" id="doaction" class="button-secondary action" />
</div>

<div class="clear"></div>

<table class="widefat post fixed" cellspacing="0">
	<thead>
		<tr>
			<th scope="col" class="check-column"><input type="checkbox" /></th>
			<th scope="col"><?php _e('Name'); ?></th>
			<th scope="col"><?php _e('Location'); ?></th>
			<th scope="col"><?php _e('Tagline'); ?></th>
			<th scope="col"><?php _e('Status'); ?></th>
		</tr>
	</thead>
	<tbody>
		<?php foreach ($results as $result) { ?>
			<tr valign="top">
				<th scope="row" class="check-column"><input type="checkbox" name="id[]" value="<?php echo $result->prop_id; ?>" /></th>
				<td><strong><?php echo $result->name; ?></strong></td>
				<td><?php echo $result->address1; ?></td>
				<td><?php echo $result->tagline; ?></td>
				<td><?php echo $result->status; ?></td>
			</tr>
		<?php } ?>
	</tbody>
</table>